package cn.net.xyan.blossom.core.entity

import cn.net.xyan.blossom.core.utils.remoteAddr
import org.hibernate.annotations.GenericGenerator
import java.util.*
import javax.persistence.*

@Entity
@Table(name = "sys_audit_log")
data class AuditLog(var type:String,
                    @Column(name = "content", length = Integer.MAX_VALUE)
                    @Lob
                    var content:String){
    companion object {
        const val Request = "Request"
        const val Response = "Response"
        const val Exception = "Exception"
        const val Info = "Info"
    }

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    var uuid:String? = null

    @Temporal(TemporalType.TIMESTAMP)
    val date: Date = Date()

    @Column(updatable = false)
    val remote:String? = remoteAddr()

    var targetClassName:String? = null

    var targetMethodName:String? = null

    var username: String? = null

}